<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*
 summary : 文章索引视图
 author : Steven Wang
 date : 19 Oct,2011
*/
class V_ArticleIndex extends CI_Model
{
	protected $_name = "v_article_index";

	/*
	 summary : 获取下一篇文章的基本信息
	 author : Steven Wang
	 date : 19 Oct,2011

	 params :
	 <int>$currentId : 当前的文章ID
	 return :
	 array{
	 	"Blog_Article_ID" => ...
	 	"Blog_Article_Title" => ...
	 }
	*/
	function getNext($currentId)
	{
		$query = $this->db
					->select(array("*"))
					->from($this->_name)
					->where("Blog_Article_ID < ".$currentId)
					->order_by("Blog_Article_ID","DESC")
					->limit(1)
					->get();
		$result = $query->result_array();
		if(count($result) > 0)
			return $result[0];
		else
			return null;
	}

	/*
	 summary : 获取上一篇文章的基本信息
	 author : Steven Wang
	 date : 19 Oct,2011

	 params :
	 <int>$currentId : 当前的文章ID
	 return :
	 array{
	 	"Blog_Article_ID" => ...
	 	"Blog_Article_Title" => ...
	 }
	*/
	function getPrevious($currentId)
	{
		$query = $this->db
					->select(array("*"))
					->from($this->_name)
					->where("Blog_Article_ID > ".$currentId)
					->order_by("Blog_Article_ID")
					->limit(1)
					->get();
		$result = $query->result_array();
		if(count($result) > 0)
			return $result[0];
		else
			return null;
	}

}






?>